package com.lzq.course.server.service;

import com.lzq.course.server.domain.Test;
import com.lzq.course.server.domain.TestExample;
import com.lzq.course.server.mapper.TestMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TestService {

    @Resource
    private TestMapper testMapper;

    /**
     * example 这个文件很有用
     * 可以帮我们生成where order 查询
     * 不用单独写sql的增删改查
     */
    public List<Test> list() {
        // 从低到高排序
        TestExample testExample = new TestExample();
        testExample.setOrderByClause("id desc");
        // 只查id = 111 createCriteria准则
        testExample.createCriteria().andIdEqualTo(111);
        // 查询所有
        return testMapper.selectByExample(testExample);
    }
}
